<?php

namespace common\models\trade;

use common\models\admin\AdminUser;
use Yii;

/**
 * This is the model class for table "{{%platform_import_batch}}".
 *
 * @property int $id
 * @property int $admin_id 操作人id
 * @property int $total_count 导入记录总数
 * @property int $success_count 校验成功数
 * @property int $error_count 校验失败数
 * @property string $type 批次类型 alipay 支付宝 | wechat 微信
 * @property int $balance 收支类型 1 支付 | -1 退款 
 * @property int $created_at 创建时间
 * @property int $updated_at 更新时间
 */
class PlatFormImportBatch extends \common\db\ActiveRecord {

    use \common\traits\Constants;
    use \common\traits\TimestampBehavior;

    const TYPE_SHOPBUY = 'shopbuy';
    const TYPE_SHOPREFUND = 'shoprefund';

    /**
     * @inheritdoc
     */
    public static function tableName() {
        return '{{%platform_import_batch}}';
    }

    /**
     * @inheritdoc
     */
    public function rules() {
        return [
            [['admin_id', 'total_count', 'success_count', 'error_count', 'balance', 'created_at', 'updated_at'], 'integer'],
            [['type'], 'string', 'max' => 20],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'admin_id' => 'Admin ID',
            'total_count' => 'Total Count',
            'success_count' => 'Success Count',
            'error_count' => 'Error Count',
            'type' => 'Type',
            'balance' => 'Balance',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }

    public function getAdmin() {
        return $this->hasOne(AdminUser::className(), ['id' => 'admin_id']);
    }

}
